﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsoleApp_EXL;
using NPOI.SS.UserModel;

namespace ET
{
    public static class GetClassInstances
    {
        
        public static List<InputTableRow> GetClassInstancesFromTable(ISheet sheet)
        {
            List<InputTableRow>? instanceList = new List<InputTableRow>();
            for (int i = 1; i <= sheet.LastRowNum; i++)
            {
                IRow row = sheet.GetRow(i);

                InputTableRow inputTableRow = new InputTableRow();

                inputTableRow.Adress = row.GetCell(0).ToString();

                inputTableRow.Notes = row.GetCell(1).ToString();

                inputTableRow.Name = row.GetCell(2).ToString();

                inputTableRow.Group = row.GetCell(3).ToString();

                inputTableRow.Group2 = row.GetCell(4).ToString();

                if (inputTableRow.Adress.StartsWith("I"))
                {
                    inputTableRow.InOut = "In";
                }

                else if (inputTableRow.Adress.StartsWith("Q"))
                {
                    inputTableRow.InOut = "Out";
                }

                if (inputTableRow.Adress.StartsWith("IW") | inputTableRow.Adress.StartsWith("QW"))
                {
                    inputTableRow.Type = "Word";
                }
                else
                {
                    inputTableRow.Type = "Bool";
                }
                instanceList.Add(inputTableRow);
            }

            return instanceList;
        }
    }
}
